var backToTopLink = $('#back-to-top-link'); 

var backToTopLinkClick = function(sender) {
	sender.preventDefault();
    $('html, body').animate({ 'scrollTop' : 0 }, 1000);
};

$(document).ready(function() {
	backToTopLink.unbind('click');
	backToTopLink.click(backToTopLinkClick);
});

$(window).scroll(function() {
    if ($(this).scrollTop()) backToTopLink.fadeIn();
    else backToTopLink.fadeOut();
});